home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Griffith 0.9.8 / griffith-0.9.8-win32.exe / {app} / lib / plugins / movie / PluginMovieCSFD.py < prev    next >
Text File  |  2008-11-17  |  5KB  |  173 lines

  1. # -*- coding: cp1250 -*-
  2. __revision__ = '$Id: PluginMovieCSFD.py 12 2007-01-05 09:08:06Z blondak $'
  3. # Copyright (c) 2005 Blondak
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU Library General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18.  
  19. # You may use and distribute this software under the terms of the
  20. # GNU General Public License, version 2 or later
  21.  
  22. import gutils
  23. import movie,string
  24. import re
  25.  
  26. plugin_name = "CSFD"
  27. plugin_description = "Cesko-Slovenska Filmova Databaze"
  28. plugin_url = "www.csfd.cz"
  29. plugin_language = _("Czech")
  30. plugin_author = "Blondak"
  31. plugin_author_email = "<blondak@neser.cz>"
  32. plugin_version = "0.8"
  33.  
  34. class Plugin(movie.Movie):
  35.     def __init__(self, id):
  36.         self.movie_id = id
  37.         self.encode = "cp1250"
  38.         self.url = "http://www.csfd.cz/"+str(id)
  39.  
  40.     def get_image(self):
  41.         self.image_url = re.search(r"background=\"http://img.csfd.cz/posters/([^\"]*)\"",self.page)
  42.         if self.image_url:
  43.             self.image_url = "http://img.csfd.cz/posters/" + gutils.strip_tags(self.image_url.group(1))
  44.         else:
  45.             self.image_url = ""
  46.  
  47.     def get_o_title(self):
  48.         self.o_title = re.findall(r"/images/flag_[\d]+\.gif'[^>]*></td><td>([^<]*)",self.page)
  49.         if len(self.o_title)>0:
  50.             self.o_title = self.o_title[len(self.o_title)-1]
  51.         else:
  52.             self.o_title = ""
  53.         if self.o_title == "":
  54.             self.o_title = self.get_title(True)
  55.  
  56.     def get_title(self, ret=False):
  57.         data = re.search(r"<title>([^,]*), ",self.page)
  58.         if data:
  59.             data = data.group(1)
  60.         else:
  61.             data = ""
  62.         if ret is True:
  63.             return data
  64.         else:
  65.             self.title = data
  66.  
  67.     def get_director(self):
  68.         self.director = re.search(r"Re₧ie:(.*)<br><b>Hrajφ:",self.page)
  69.         if self.director:
  70.             self.director = gutils.strip_tags(self.director.group(1))
  71.         else:
  72.             self.director = ""
  73.  
  74.     def get_year(self):
  75.         self.year = re.search(r"<title>.*\(([\d]+)\)",self.page)
  76.         if self.year:
  77.             self.year = self.year.group(1)
  78.         else:
  79.             self.year = ""
  80.  
  81.     def get_runtime(self):
  82.         self.runtime = re.search(r"([\d]+) min</b><BR><BR><b>Re₧ie:",self.page)
  83.         if self.runtime:
  84.             self.runtime = gutils.strip_tags(self.runtime.group(1))
  85.         else:
  86.             self.runtime = ""
  87.  
  88.     def get_genre(self):
  89.         self.genre = re.search(r"/images/flag_[\d]+.gif.*</table>[\s]*<br>[\s]*<b>([^&:]*) <br>",self.page)
  90.         if self.genre:
  91.             self.genre = gutils.strip_tags(self.genre.group(1))
  92.         else:
  93.             self.genre = ""
  94.  
  95.     def get_country(self):
  96.         self.country = re.search(r"/images/flag_[\d]+.gif.*</table>[\s]*<br>[\s]*<b>[^&:]* <br>(.*), [\d]{4}, ",self.page)
  97.         if self.country:
  98.             self.country = gutils.strip_tags(self.country.group(1))
  99.         else:
  100.             self.country = ""
  101.  
  102.     def get_cast(self):
  103.         self.cast = re.search(r"Hrajφ: (.*)</div><br>",self.page)
  104.         if self.cast:
  105.             self.cast = gutils.strip_tags(self.cast.group(1))
  106.         else:
  107.             self.cast = ""
  108.  
  109.     def get_plot(self):
  110.         self.plot = gutils.strip_tags(string.replace(gutils.trim(self.page,"Obsah / Info:","</td>"),"(oficißlnφ text distributora)",""))
  111.  
  112.     def get_site(self):
  113.         self.site = re.search(r"href=[\"'](http://.*imdb\.com/title/[^\"']*)",self.page)
  114.         if self.site:
  115.             self.site = gutils.strip_tags(self.site.group(1))
  116.         else:
  117.             self.site = ""
  118.  
  119.     def get_trailer(self):
  120.         self.trailer = re.search(r"<a href=\"([^\"]*)\"[^>]*>trailer<br><img src=\"http://img.csfd.cz/images/new/film/ikona_trailer",self.page)
  121.         if self.trailer:
  122.             self.trailer = "http://www.csfd.cz/"+gutils.strip_tags(self.trailer.group(1))
  123.  
  124.         else:
  125.             self.trailer = ""
  126.  
  127.     def get_rating(self):
  128.         self.rating = re.search(r"[\s]*([\d]+)%[\s]*</td>",self.page)
  129.         if self.rating:
  130.             self.rating = str(float(self.rating.group(1))/10)
  131.         else:
  132.             self.rating = ""
  133.  
  134.     def get_o_site(self):
  135.         self.o_site = re.search(r"href=\"([^\"]*)\"[^>]*>www<br><img src=\"http://img.csfd.cz/images/new/film/ikona_www",self.page)
  136.         if self.o_site:
  137.             self.o_site = gutils.strip_tags(self.o_site.group(1))
  138.         else:
  139.             self.o_site = ""
  140.  
  141.     def get_notes(self):
  142.         self.notes = ""
  143.  
  144.     def get_studio(self):
  145.         self.studio = ""
  146.  
  147.     def get_classification(self):
  148.         self.classification = ""
  149.  
  150. class SearchPlugin(movie.SearchMovie):
  151.     def __init__(self):
  152.         self.encode = "cp1250"
  153.         self.original_url_search   = "http://www.csfd.cz/search_pg.php?search="
  154.         self.translated_url_search = "http://www.csfd.cz/search_pg.php?search="
  155.  
  156.     def search(self,parent_window):
  157.         self.open_search(parent_window)
  158.         return self.page
  159.  
  160.     def get_searches(self):
  161.         tmp_id = self.re_items=re.search(r"window.location.href='http://www.csfd.cz/(/film/[^']*)'",self.page)
  162.         if tmp_id:
  163.             self.ids.append(tmp_id.group(1))
  164.         else:
  165.             self.re_items=re.findall(r"href=\"(/film/[^\"]+)[^>]*>([^<]+)</a>([^<]*)",self.page)
  166.             self.number_results = len(self.re_items)
  167.             if (self.number_results > 0):
  168.                 for item in self.re_items:
  169.                     self.ids.append(item[0])
  170. #                    self.titles.append(gutils.convert_entities(item[1])+' '+item[2])
  171.                     self.titles.append(item[1]+' '+item[2])
  172.  
  173.